/********************************************************************
 * Copyright(c) 2023-2023 Grayson Zheng.
 * File: delay.h
 * Description: Delay function library based on 11.0592MHz
 * crystal oscillator.
 * Version: 1.0
 * Date: 2023-07-17
 * Author: zhengxinyu13@qq.com
 * ---------- Revision History ----------
 * <version>
 * <date>
 * <author>
 * <desc>
 * Modified to be suitable to the new coding rules in all functions.
 ********************************************************************/

#include "delay.h"
#include "intrins.h"

/* This header file only contains common delay functions, 
 * and there are certain errors. You can use the STC-ISP
 * software delay calculator to automatically generate code.
 */
void delay_10us(void)
{
	uint_8 i = 2;
	while (--i);
}

void delay_xms(uint_16 xms)
{
	uint_16 i,j;
	for (i = 0; i < xms; i++)
		for (j = 0; j < 112; j++);
}

void delay_1s(void)
{
	uint_8 i, j, k;

	_nop_();
	i = 8;
	j = 1;
	k = 243;
	do {
		do {
			while (--k);
		} while (--j);
	} while (--i);
}
